package com.huike.game.Activity;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import com.huike.game.R;
import com.huike.game.adapter.HhAdapter;
import com.huike.game.api.Api;
import com.huike.game.qingqing.Ben22;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class Chong extends AppCompatActivity {
  String TAG="log";
    ImageView imageView;
    TextView textView;
    Context context;
    RequestQueue queue=null;
    ArrayList<Ben22.DataBean> arl=new ArrayList<Ben22.DataBean>();
   HhAdapter aa;
    
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chong);
        imageView=findViewById(R.id.im_1);
        textView=findViewById(R.id.tv1);
        context=context;
        queue=Volley.newRequestQueue(context);

         getData();
         aa=new HhAdapter(this.arl,context);

        
        
        
        
    }

    private void getData() {
     JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(
             Request.Method.POST,
             Api.USER_INFO,
             new Response.Listener<JSONObject>() {
                 @Override
                 public void onResponse(JSONObject jsonObject) {
                     Log.e(TAG, "onResponse: "+jsonObject );
                     Gson gson=new Gson();
                     Ben22 ben22 = gson.fromJson(jsonObject.toString(), Ben22.class);
                     List<Ben22.DataBean> data = ben22.getData();
                     for (Ben22.DataBean b:data){
                         arl.add(b);
                     }
                     aa.notifyDataSetChanged();



                 }
             }, new Response.ErrorListener() {

         public void onErrorResponse(VolleyError volleyError) {
             Log.e(TAG, "onErrorResponse: "+volleyError );

         }
     }

     );





}
}
